﻿using System;
using Genko.Model.Schema;

namespace Genko.Model
{
	public class ObjectMember : Member
	{
		protected internal ClassType type = null; 

		internal ObjectMember()
		{

		}

		/// <summary>
		/// Gets the Model to which this Object belongs. Can be null
		/// </summary>
		public virtual Model Model
		{
			get
			{
				if (this.Owner is Scheme) {
					return null;
				}
				if (this is Model) {
					return (Model)this;
				}
				return ((ObjectMember)this.Owner).Model;
			}
		}

		public override Member CreateMember(string memberName)
		{
			throw new Exception("The method or operation is not implemented.");
		}

		public override bool CanBeAttached(Member member)
		{
			return (member is ObjectMember);
		}

		public virtual ClassType Type
		{
			get {
				return this.type;
			}
		}
	}
}
